<?php

namespace App\Models;

use App\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\AdminMenu
 *
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property string|null $icon 圖標
 * @property int $id
 * @property string|null $name 名稱
 * @property int $parent_id 父ID
 * @property int $sort 排序
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property string $uri 路徑
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\AdminMenu[] $childrens
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereIcon($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereParentId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereSort($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu whereUri($value)
 * @mixin \Eloquent
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminMenu query()
 */
class AdminMenu extends Model
{
    use ModelTree;

    protected $fillable = [
        'parent_id',
        'sort',
        'name',
        'icon',
        'uri',
    ];

    public function childrens()
    {
        return $this->hasMany(self::class, 'parent_id', 'id');
    }
}
